package com.sunshine.ssm.test;

import java.util.Random;

/**
 * @Description: 获取随机6位数验证码
 * @author: Hong.Wei
 * @Date: 2017/1/3 9:12
 */
public class RandNum {

    public static void main(String[] args) {
        for (int i = 0; i < 100; i++){
                System.out.println(getRandNum());
        }
    }

    /**
     * 获取随机6位数验证码
     * @return
     */
    public static int getRandNum() {
        Random random = new Random();
        int randNum = random.nextInt(1000000);
        if (String.valueOf(randNum).length() != 6) {
            return getRandNum();
        }
        return randNum;
    }
}
